package com.imranstechnology.homeexpensemanager;

import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;

public class ExpenseEntity {
	private float totalExpense;
	private float yearlyExpense;
	private float monthlyExpense;
	private float dailyExpense;
	private Date lastSavingDate;
	private Map<Integer,List<ExpenseDetailEntity>> yearsTrnx = new HashMap<Integer, List<ExpenseDetailEntity>>(1);
	public ExpenseEntity() {
		super();
	}
	public ExpenseEntity(float totalExpense, float yearlyExpense, float monthlyExpense,
			float dailyExpense, Date lastSavingDate) {
		super();
		this.totalExpense = totalExpense;
		this.yearlyExpense = yearlyExpense;
		this.monthlyExpense = monthlyExpense;
		this.dailyExpense = dailyExpense;
		this.lastSavingDate = lastSavingDate;
	}
	public float getTotalExpense() {
		return totalExpense;
	}
	public void setTotalExpense(float totalExpense) {
		this.totalExpense = totalExpense;
	}
	public float getMonthlyExpense() {
		return monthlyExpense;
	}
	public void setMonthlyExpense(float monthlyExpense) {
		this.monthlyExpense = monthlyExpense;
	}
	public float getDailyExpense() {
		return dailyExpense;
	}
	public void setDailyExpense(float dailyExpense) {
		this.dailyExpense = dailyExpense;
	}
	public Date getLastSavingDate() {
		return lastSavingDate;
	}
	public void setLastSavingDate(Date lastSavingDate) {
		this.lastSavingDate = lastSavingDate;
	}
	public void setYearlyExpense(float yearlyExpense) {
		this.yearlyExpense = yearlyExpense;
	}
	public float getYearlyExpense() {
		return yearlyExpense;
	}
	public void addDetail(Integer year, ExpenseDetailEntity record){
		List<ExpenseDetailEntity> records = yearsTrnx.get(year);
		if(records == null)
		{
			records = new ArrayList<ExpenseDetailEntity>();
			yearsTrnx.put(year, records);
		}
		records.add(record);
	}
	public List<ExpenseDetailEntity> getYearRecords(Integer year){
		List<ExpenseDetailEntity> res = yearsTrnx.get(year);
		if(res == null)
		{
			res = new ArrayList<ExpenseDetailEntity>(0);
		}
		return res;
	}
	public Map<Integer, List<ExpenseDetailEntity>> getYearsTrnx() {
		return yearsTrnx;
	}
	public Set<String> getYearRecordSet(Integer year){
		List<ExpenseDetailEntity> res = yearsTrnx.get(year);
		Set<String> result = new HashSet<String>();
		if(res != null)
		{
			for(ExpenseDetailEntity e:res){
				result.add(e.toString());
			}
		}
		return result;
	}
}
